package com.cmj.controller;

import com.cmj.domain.ResponseResult;
import com.cmj.domain.dto.RoleAddDto;
import com.cmj.domain.dto.RoleDto;
import com.cmj.domain.dto.RoleStatusDto;
import com.cmj.domain.entity.Role;
import com.cmj.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 这是注释
 */
@RestController
@RequestMapping("/system/role")
public class RoleController {
    @Autowired
    private RoleService roleService;

    /***
     * 获取友链
     * @return 返回友链
     */
    @GetMapping("/listAllRole")
    public ResponseResult<Role> listAllRole(){
        return roleService.listAllRole();
    }

    @GetMapping("/list")
    public ResponseResult getRoleList(Integer pageNum, Integer pageSize, RoleDto roleDto){
        return roleService.getRoleList(pageNum,pageSize,roleDto);
    }

    @DeleteMapping("{ids}")
    public ResponseResult delRole(@PathVariable("ids") Integer[] ids){
        return roleService.delRole(ids);
    }

    @PutMapping("/changeStatus")
    public ResponseResult changeStatus(@RequestBody RoleStatusDto role){
        return roleService.changeStatus(role);
    }

    @PostMapping
    public ResponseResult addRole(@RequestBody RoleAddDto roleAddDto){
        return roleService.addRole(roleAddDto);
    }

    @GetMapping("{id}")
    public ResponseResult getUserRole(@PathVariable("id") Long id){
        return roleService.getUserRole(id);
    }
}
